function [b a] = build_filter_multipe_bandpass(Fs,frequencies)

% function build_filter.m(arg#1,arg#2,...)
%
% The function filters the data
% filters: 
% Parameter         Value
% ---------         -----
%   'notch'         a notch filter (half amplitude band width 1Hz) with
%                       central frequency specified by the user (in Hz)
%
%   'HP'            a high pass filter (butterworth order 4) with cut off
%                       frequency specified by the user (in Hz)
%
%   'LP'            a low pass filter (butterworth order 4) with cut off
%                       frequency specified by the user (in Hz)
%
%   'feedback'      set true for visual feedback 
%
% Reference: SK Mitra: Digital Signal Processing, Mc Graw Hill 2001, 2nd
% ed., pp 433-435

sos = [];

for i=1:length(frequencies)
    
     f = frequencies{i};
     [z,p,k] = butter(2,f(1)/Fs*2,'high');
     sos     = [sos; zp2sos(z,p,k)];
     
     [z,p,k] = butter(2,f(2)/Fs*2,'low');
     sos     = [sos; zp2sos(z,p,k)];
        
end;

% Filtering only needed if the user effectively gives parameters, otherwise
% do nothing
% % if nargin > 0
    [b,a] = sos2tf(sos); % from second order structure to transfer function